package user

import "github.com/gogf/gf/v2/frame/g"

// 登录
type LoginReq struct {
	g.Meta   `path:"/users/login" method:"post" sm:"登录" tags:"用户"`
	Mobile   string `json:"mobile" v:"required|length:11,13"`
	Password string `json:"password" v:"required|length:6,16"`
}

type LoginRes struct {
	UserId int64  `json:"userId"`
	Token  string `json:"token" dc:"在需要鉴权的接口中header加入Authorization: token"`
}

// 创建用户
type CreateUserReq struct {
	g.Meta   `path:"/users" method:"post" sm:"创建用户" tags:"创建用户"`
	Nickname string `json:"nickname" v:"required|length:3,12"`
	Password string `json:"password" v:"required|length:6,16"`
	Mobile   string `json:"mobile" v:"required|length:11,13"`
	Birthday string `json:"birthday"`
	Role     string `json:"role"`
}

type CreateUserRes struct {
	UserId int64 `json:"userId"`
}

// 更新用户信息
type UpdateUserReq struct {
	g.Meta   `path:"/users" method:"put" sm:"更新用户信息" tags:"更新用户信息"`
	Nickname string `json:"nickname" v:"required|length:3,12"`
	Password string `json:"password" v:"required|length:6,16"`
	Mobile   string `json:"mobile" v:"required|length:11,13"`
	Birthday string `json:"birthday"`
	Role     string `json:"role"`
}

type UpdateUserRes struct {
	UserId  int64 `json:"userId"`
	Success bool  `json:"success"`
}

// 用户列表
type UserPageReq struct {
	g.Meta `path:"/users" method:"get" sm:"用户列表" tags:"用户列表"`
	Page   int64 `json:"page"`
	Size   int64 `json:"size"`
}
type UserPageRes struct {
	Total     int64          `json:"total"`
	Page      int64          `json:"page"`
	Size      int64          `json:"size"`
	UserInfos []*UserInfoRes `json:"user_infos"`
}

// 获取用户信息(id)
type UserInfoReq struct {
	g.Meta `path:"/users/{id}" method:"get" sm:"获取用户信息" tags:"获取用户信息"`
}

type UserInfoReqByMobile struct {
	g.Meta `path:"/users/{mobile}" method:"get" sm:"根据mobile获取用户信息" tags:"根据mobile获取用户信息"`
}

type UserInfoRes struct {
	Id       int64  `json:"id"`
	Nickname string `json:"nickname"`
	Password string `json:"password"`
	Mobile   string `json:"mobile"`
	Birthday string `json:"birthday"`
	Role     string `json:"role"`
}

// 删除用户
type DeleteUserReq struct {
	g.Meta `path:"/users/{id}" method:"delete" sm:"删除用户" tags:"删除用户"`
}

type DeleteUserRes struct {
	UserId  int64 `json:"userId"`
	Success bool  `json:"success"`
}
